<template>
  <div class="home-page">
    <!-- 核心交互卡片 -->
    <div class="core-card">
      <!-- 左侧：3D数字人形象 -->
      <div class="digital-human-container">
        <DigitalHuman 
          :emotion="currentEmotion" 
          :action="currentAction"
          @animation-end="onAnimationEnd"
        />
      </div>
      
      <!-- 右侧：引导文案区 -->
      <div class="guide-content">
        <h1 class="main-title">您好！我是您的智能导诊助手</h1>
        <p class="sub-title">描述您的症状，我来帮您推荐科室、生成病历</p>
        <div class="action-buttons">
          <el-button 
            type="primary" 
            size="large" 
            @click="startVoiceConsult"
            :icon="Microphone"
          >
            开始语音问诊
          </el-button>
          <el-button 
            type="info" 
            size="large" 
            @click="startTextConsult"
            :icon="Edit"
          >
            文字输入症状
          </el-button>
        </div>
      </div>
    </div>
    
    <!-- 快捷功能区 -->
    <div class="quick-actions">
      <div 
        class="quick-action-card" 
        v-for="action in quickActions" 
        :key="action.name"
        @click="goToPage(action.path)"
      >
        <el-icon size="24" color="#3B82F6"><component :is="action.icon" /></el-icon>
        <span class="action-text">{{ action.name }}</span>
      </div>
    </div>
  </div>
</template>

<script>
import { defineComponent, ref, onMounted } from 'vue'
import { ElButton, ElIcon } from 'element-plus'
import { Microphone, Edit, OfficeBuilding, User, Document } from '@element-plus/icons-vue'
import { useRouter } from 'vue-router'
import DigitalHuman from '@/components/DigitalHuman.vue'

export default defineComponent({
  name: 'Home',
  components: {
    ElButton,
    ElIcon,
    DigitalHuman,
    OfficeBuilding,
    User,
    Document
  },
  setup() {
    const router = useRouter()
    
    // 数字人状态
    const currentEmotion = ref('smile')
    const currentAction = ref('idle')
    
    // 快捷功能
    const quickActions = [
      { name: '科室查询', icon: 'OfficeBuilding', path: '/department-recommend' },
      { name: '排队查询', icon: 'User', path: '/queue' },
      { name: '病历查询', icon: 'Document', path: '/medical-record' }
    ]
    
    // 数字人动画结束回调
    const onAnimationEnd = () => {
      // 可以在这里处理动画结束后的逻辑
    }
    
    // 开始语音问诊
    const startVoiceConsult = () => {
      router.push('/consult')
    }
    
    // 开始文字问诊
    const startTextConsult = () => {
      router.push('/consult')
    }
    
    // 跳转到指定页面
    const goToPage = (path) => {
      router.push(path)
    }
    
    // 页面加载完成后，数字人自动播放欢迎语音
    onMounted(() => {
      // 这里可以添加播放欢迎语音的逻辑
      console.log('欢迎使用医联智导，我将为您提供专业的导诊服务')
    })
    
    return {
      currentEmotion,
      currentAction,
      quickActions,
      Microphone,
      Edit,
      onAnimationEnd,
      startVoiceConsult,
      startTextConsult,
      goToPage
    }
  }
})
</script>

<style scoped>
.home-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.core-card {
  display: flex;
  gap: 40px;
  background: white;
  border-radius: 12px;
  padding: 40px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  margin-bottom: 40px;
}

.digital-human-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
}

.guide-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.main-title {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 16px;
  color: #333;
}

.sub-title {
  font-size: 16px;
  color: #666;
  margin-bottom: 32px;
}

.action-buttons {
  display: flex;
  gap: 16px;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.quick-action-card {
  background: white;
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.quick-action-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.1);
}

.action-text {
  display: block;
  margin-top: 12px;
  font-size: 16px;
  color: #333;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .core-card {
    flex-direction: column;
    padding: 20px;
  }
  
  .action-buttons {
    flex-direction: column;
  }
  
  .quick-actions {
    grid-template-columns: 1fr;
  }
}
</style>